package top.wangxiaomei.ai.other;

import lombok.Getter;
import lombok.Setter;

import java.util.HashMap;
import java.util.List;

@Getter
@Setter
public class WordEX {
    int index;
    int len;
    String word;
    List<Abs> ex;
    public WordEX(int index, String word, List<Abs> ex) {
        this.index = index;
        this.word = word;
        this.ex = ex;
        this.len = word.length();
    }
    public WordEX( String word, List<Abs> ex) {
        this.index = 0;
        this.word = word;
        this.ex = ex;
        this.len = word.length();
    }
    private String exToString() {
        StringBuilder sb = new StringBuilder();
        for (Abs abs : ex) {
            sb.append(abs.toString());
            // 如果不是最后一个，则添加一个逗号
            if (abs!= ex.getLast()) sb.append("、");
        }
        return sb.toString();
    }

    @Override
    public String toString() {
        return word + ":[" +
                exToString()
                + "]";
    }
}
